home *** CD-ROM | disk | FTP | other *** search
/ Scene Storm / Scene Storm - Volume 1.iso / coding / c / amiexpress / source / ae / code / ax3.00 / random.c < prev    next >
Encoding:
C/C++ Source or Header  |  1980-01-03  |  532 b   |  37 lines

  1. #include <exec/types.h>
  2. #include <dos/dosextens.h>
  3. #include <time.h>
  4. #include <stdlib.h>
  5. #include <fcntl.h>
  6. #include <stdio.h>
  7. #include "bbs.protos"
  8.  
  9. void Randomize(void)
  10. {
  11.    long timet;
  12.    long t;
  13.  
  14.   timet=time((APTR)&t);
  15.    srand(timet);
  16. }
  17.  
  18. int rnd(int x)
  19. {
  20.   int i;
  21.   if(x<=0) return(0);
  22.   Randomize();
  23.   do  {
  24.     i=rand()%x;
  25.   }
  26.   while(i>x);
  27.   return(i);
  28. }
  29.  
  30. void rand_color(void)
  31. {
  32.  char colorbuff[6]={0x1B, 0x5B, 0x33, 0x31, 0x6D, 0x00};  /* Removed space 0A */
  33.  
  34.  colorbuff[3] = (rand() % 6) + 0x31;
  35.  AEPutStr(colorbuff);
  36. }
  37.